#include <iostream>
#include <vector>
using namespace std;

//S(m,n)=S(m,n−1)+S(m−n,n)，边界  S(0,n)=1, S(m,0)=0 (m > 0)
int max_nums(int m, int n)
{
        if(m == 0){
                return 1;
        }

        if(n == 0){
                return 0;
        }

        int meths = max_nums(m, n - 1);
        if(m >= n){
                meths += max_nums(m - n, n);
        }
        return meths;
}
int main()
{
        int t;
        cin>>t;

        while(t--){
                int m, n;
                cin>>m>>n;
                cout<<max_nums(m, n)<<endl;
        }

        return 0;
}
/*
1
1 1
*/